<template>
  <div class="app-container">
    <h5 class="titleInfo">医院信息</h5>
    <el-form label-width="130px" :model="sunnaryInfo"  ref="form" :disabled="disabflag">
      <el-row>
        <el-col :span="24">
          <el-form-item label="医院名称" prop="hospitalName">
            <el-select v-model="sunnaryInfo.hospitalName" clearable filterable placeholder="请选择">
              <el-option
                v-for="item in hospitalOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="医院级别" prop="hospitalLvl">
            <el-select v-model="sunnaryInfo.hospitalLvl" clearable placeholder="请选择">
              <el-option
                v-for="item in tagOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="所属分公司" prop="branchOfficeName">
            <div style="padding-top: 10px;">
              <el-select v-model="sunnaryInfo.branchOfficeName" clearable placeholder="请选择">
                <el-option
                  v-for="item in officeOption"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="APP上架状态" prop="appStatus">
            <div style="padding-top: 10px;">
              <el-select v-model="sunnaryInfo.appStatus">
                <el-option
                  v-for="item in appStatusOption"
                  :key="item.id"
                  :label="item.lable"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="严选状态" prop="examStatus">
            <div style="padding-top: 10px;">
              <el-select v-model="sunnaryInfo.examStatus">
                <el-option
                  v-for="item in examStatusOption"
                  :key="item.id"
                  :label="item.lable"
                  :value="item.value"
                ></el-option>
              </el-select>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <h5 class="titleInfo">概述</h5>
    <el-form label-width="130px" :model="sunnaryInfo" :disabled="flag" :rules="rules" ref="ruleForm">
      <el-row>
        <el-col :span="6">
          <el-form-item label="总体评分" prop="examScore" >
            <el-input v-model="sunnaryInfo.examScore" style="width:60%;" type="text" size="small" disabled></el-input>
            <span>分</span>
          </el-form-item>
        </el-col>
        <el-col :span="24"> 
          <el-form-item label="安全指数" prop="safetyScore" >
            <el-rate v-model="sunnaryInfo.safetyScore" ></el-rate>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="环境指数" prop="envScore" >
            <div style="padding-top: 10px;">
              <el-rate v-model="sunnaryInfo.envScore" ></el-rate>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="服务指数" prop="serviceScore">
            <div style="padding-top: 10px;">
              <el-rate v-model="sunnaryInfo.serviceScore" ></el-rate>
            </div>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="报告概述" prop="reportDesc">
            <div style="padding-top: 10px;">
              <el-input type="textarea" v-model="sunnaryInfo.reportDesc" maxlength="300" show-word-limit=true autosize></el-input>
              <!-- {{sunnaryInfo}} -->
            </div>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>
<script>
import { hospitalList } from "@/api/financialBack";
import { findHospitalTagsList } from "@/api/hospitalLabel";
import { companyList } from "@/api/branchOfficeDropDown";
export default {
  props: {
    officeOption: {
      type: Array,
      default: []
    },
    tagOption: {
      type: Array,
      default: () => {
        return [];
      }
    },
    hospitalOptions: {
      type: Array,
      default: () => {
        return [];
      }
    },
    sunnaryInfo: {
      type: Object,
      default: () => {
        return {};
      }
    },
    tag: {
      type: Number,
      default: () => {
        return null;
      }
    }
  },
  // props:["sunnaryInfo"],
  data() {
    return {
      disabflag:true,
      flag: true,
      hospitalId: "",
      form: {
        hospitalId: null,
        tagsId: null,
        officeId: null,
        appStatus: null,
        examStatus: "",
        examScore: null,
        safetyScore: null,
        envScore: null,
        serviceScore: null,
        reportDesc: null
      },
      appStatusOption: [
        { lable: "上架", value: 0 },
        { lable: "未上架", value: 1 }
      ],
      examStatusOption: [
        { lable: "未严选", value: 0 },
        { lable: "严选通过", value: 1 }
      ],
      rules: {
        safetyScore: [
         {
            required: true,
            message: "请输入安全指数",
            trigger: "blur"
          }
        ],envScore: [
         {
            required: true,
            message: "请输入环境指数",
            trigger: "blur"
          }
        ],serviceScore: [
         {
            required: true,
            message: "请输入服务指数",
            trigger: "blur"
          }
        ],
        reportDesc: [
         {
            required: true,
            message: "请输入报告概述",
            trigger: "blur"
          }
        ],
      },
    };
  },
  mounted(){
  },
  created() {
    // console.log("this.hospitalOptions", this.hospitalOptions);
    // console.log(this.sunnaryInfo)
    // this.getFatherInfo()
    // this.form.hospitalId = String(this.$route.query.userId) ;
    // if ( this.type != 1) {
    //   console.log("this.type", this.type);
    //   this.flag = false;
    // }
    console.log("this.tag", this.tag);
    if (this.tag == 2) {
      this.flag=false
    }else if(this.tag==3){
      this.flag = false;
    }
  },
  // watch: { sunnaryInfo: function(val){
  //   console.log(val)
  //   if(val){
  //     this.form=val
  //       }
  //     }
  //   },
  methods: {
    //子组件校验，传递到父组件
      validateForm () {
        let flag = null
        this.$refs['ruleForm'].validate(valid => {
          if (valid) {
            flag = true
          } else {
            flag = false
          }
        })
        return flag
      },
    // checkfn() {
      // let abc = "";
      // this.$refs["sunnaryInfo"].validate(valid => {
      //   console.log(123, valid);

      //   if (valid) {
      //     abc = true;
      //   } else {
      //     this.$message({
      //       message: "请完善信息再提交",
      //       type: "warning"
      //     });
      //     abc = false;
      //   }
      // });
      // return abc;
    // },
  }
};
</script>
